<?php

declare(strict_types=1);

namespace app\shop\controller\admin\commission;

use sheep\controller\Backend;
use app\shop\model\commission\Log as LogModel;
use sheep\controller\traits\Crud;
use think\Request;
use think\Response;
use sheep\library\Operator;

class Log extends Backend
{
    use Crud;
    protected $model = null;
    protected $isPaginate = true;

    public function initialize()
    {
        $this->model = new LogModel();
    }


    /**
     * 查看
     *
     * @return Response
     */
    public function list(Request $request): Response
    {
        $logs = $this->model->sheepFilter()->with(['agent', 'oper'])->paginate($request->param('list_rows', 10))->toArray();

        // 解析操作人信息
        foreach ($logs['data'] as &$log) {
            $log['oper'] = Operator::info($log['oper_type'], $log['oper'] ?? null);
        }
        return success('获取成功', $logs);
    }
}
